package o;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient.FileChooserParams;
import android.webkit.WebView;
import com.huawei.appgallery.agwebview.choosefile.WebViewTransferActivity;

public class azy implements azx {
    @TargetApi(21)
    public boolean ॱ(Context context, WebView webView, ValueCallback<Uri[]> valueCallback, FileChooserParams fileChooserParams) {
        boolean z = false;
        if (fileChooserParams == null) {
            valueCallback.onReceiveValue(null);
            return false;
        }
        boolean z2;
        String[] acceptTypes = fileChooserParams.getAcceptTypes();
        if (acceptTypes != null) {
            for (String str : acceptTypes) {
                if (str != null && str.contains("image")) {
                    z2 = true;
                    break;
                }
            }
        }
        z2 = false;
        if (z2) {
            String ॱ = baf.ॱ().ॱ(valueCallback);
            Intent intent = new Intent(context, WebViewTransferActivity.class);
            if (1 != fileChooserParams.getMode()) {
                z = true;
            }
            intent.putExtra("choosefile_single", z);
            intent.putExtra("choosefile_type", "image");
            intent.putExtra("callbackid", ॱ);
            ˋ(context, intent);
            return true;
        }
        azh.ˏ.ˊ("ChooseFileImpl", "onShowFileChooser no image type");
        valueCallback.onReceiveValue(null);
        return false;
    }

    private void ˋ(Context context, Intent intent) {
        intent.putExtra("oper_type", 1);
        if (context instanceof Activity) {
            context.startActivity(intent);
            return;
        }
        azl ˎ = aze.ˎ();
        if (ˎ != null) {
            ˎ.ˊ(context, WebViewTransferActivity.class, intent, false);
        }
    }
}
